
package cs235.xml;


public class ParserFactory {

    /**
     * Creates and returns an object that implements the Parser interface.
     * This is useful for parsing an existing XML document.
     * 
     * @return a new object that implements the Parser interface
     */
    public static Parser createParser() {
        	return new XMLParser();
	}

    /**
     * Creates and returns an object that implements the Document interface.
     * This is useful for creating new XML documents.
     *
     * @return a new object that implements the Document interface
     */
	public static Document createDocument() {
		return new XMLDocument();
	}
	
	/**
	* Creates a new element node.
	*
	* @param tagName the name of the element
	* @return the new element node
	* @throws IllegalArgumentException if tagName is null
	*/
	public static Element createElement(String tagName)
	{
	    XMLElement temp = new XMLElement();
	    temp.setTagName(tagName);
		return temp;
	}

	/**
	* Creates a new text node.
	*
	* @param data the text string to be stored in the new node
	* @return the new text node
	* @throws IllegalArgumentException if data is null
	*/
	public static Text createText(String data)
	{  
	    XMLText text = new XMLText();
	    text.setData(data);
		return text;
	}
	
}
